//
//  YXTopicToolbarView.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/30.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXTopicToolbarView.h"

@interface YXTopicToolbarView ()


@end

@implementation YXTopicToolbarView

- (UITextField *)contentTF {
    if (!_contentTF) {
        _contentTF = [[UITextField alloc] init];
        _contentTF.placeholder = @"写回复";
        _contentTF.borderStyle = UITextBorderStyleRoundedRect;
        _contentTF.font = [UIFont systemFontOfSize:14];
        _contentTF.returnKeyType = UIReturnKeySend;
    }
    return _contentTF;
}

- (UIButton *)sendBtn {
    if (!_sendBtn) {
        _sendBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_sendBtn setTitle:@"发送" forState:(UIControlStateNormal)];
        [_sendBtn setTitleColor:color_textTwo forState:(UIControlStateNormal)];
        [_sendBtn addTarget:self action:@selector(sendBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _sendBtn;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor py_colorWithHexString:@"#f2f2f2"];
        [self addSubview:self.sendBtn];
        [self addSubview:self.contentTF];
    }
    return self;
}

- (void)sendBtnAction:(UIButton *)sender {
    self.ClickSendBtnBlick();
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self endEditing:YES];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    YXWeakSelf
    [_sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.mas_right).offset(0);
        make.top.equalTo(weakSelf.mas_top).offset(0);
        make.size.mas_equalTo(CGSizeMake(60, 50));
    }];
    
    [_contentTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).offset(10);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.right.equalTo(weakSelf.sendBtn.mas_left).offset(0);
        make.height.offset(30);
    }];
}


@end
